#include<bits/stdc++.h>
using namespace std;
const int N=5e5+5;
long long n,k,d,a[N],t[N],top[N],bh,ans[N],tree[N*4+5];
vector<int>q[N]; 
void build(int l,int r,int id)
{
	if(l==r)
	{
		tree[id]=-1e15;
		return;
	}
	int mid=(l+r)/2;
	build(l,mid,id*2);
	build(mid+1,r,id*2+1);
	tree[id]=max(tree[id*2],tree[id*2+1]);
}
void xg(int l,int r,int nl,int nr,int id,long long z)
{
	if(l==nl&&nr==r)
	{
		tree[id]=z;
		return;
	}
	int mid=(l+r)/2;
	if(mid>=nl) xg(l,mid,nl,nr,id*2,z);
	else xg(mid+1,r,nl,nr,id*2+1,z);
	tree[id]=max(tree[id*2],tree[id*2+1]);
}
int main()
{
	freopen("holiday.in","r",stdin);
	freopen("holiday.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k>>d;
	long long z[k+5][n/k+(n%k!=0)+5];
	for(int i=0;i<=k;++i)
		for(int j=0;j<=n/k+2;++j)
			z[i][j]=0;
	for(int i=1;i<=n;++i)
		cin>>a[i];	
	for(int i=1;i<n;++i)
		cin>>t[i];
	build(0,k-1,1);
	for(int i=1;i<=n;++i)
	{
		bh=(i-1)%k;
		if(top[bh])
			xg(0,k-1,bh,bh,1,ans[z[bh][top[bh]]]-(i-z[bh][top[bh]])/k*d);
		if(i==1) ans[i]=a[i];
		else ans[i]=tree[1]+a[i];
		for(int j=0;j<q[i].size();++j)
		{
			bh=q[i][j];
			while(top[bh]>0&&t[z[bh][top[bh]]]+z[bh][top[bh]]<=i) --top[bh];
			if(top[bh]==0) xg(0,k-1,bh,bh,1,-1e15);
			else xg(0,k-1,bh,bh,1,ans[z[bh][top[bh]]]-(i-z[bh][top[bh]])/k*d);
		}
		if(i!=n)
		{
			bh=(i-1)%k;
			while(top[bh]>0&&(t[z[bh][top[bh]]]+z[bh][top[bh]]<=i||ans[z[bh][top[bh]]]-(i-z[bh][top[bh]])/k*d<ans[i]||(ans[z[bh][top[bh]]]-(i-z[bh][top[bh]])/k*d==ans[i]&&t[z[bh][top[bh]]]+z[bh][top[bh]]<=i+t[i]))) --top[bh];
			if(ans[z[bh][top[bh]]]<ans[i]||top[bh]==0)
			{
				++top[bh];
				z[bh][top[bh]]=i;
				q[i+t[i]].push_back(bh);
			}
			xg(0,k-1,bh,bh,1,ans[z[bh][top[bh]]]-(i-z[bh][top[bh]])/k*d);
		}
	}
	cout<<ans[n];
	return 0;
 } 
